<template>
  <div>
    <el-container>
      <el-header style="width: 100%;height: 100%">
        <div class="searchStyle">
          <div style="margin-top: 15px">
            <el-button size="mini" type="success" @click="initData" icon="el-icon-refresh">刷新
            </el-button>
          </div>
        </div>

      </el-header>

      <el-main style="padding-left: 1px;padding-top: 20px;height:100%">
        <div>
          <el-table :data="sanitarys" stripe v-loading="tableLoading" size="mini" style="width: 100%;">
            <el-table-column prop="listId" label="序号" width="60px" align="center"></el-table-column>
            <el-table-column prop="buildId" label="公寓编号" width="120px" align="center"></el-table-column>
            <el-table-column prop="roomId" label="宿舍号" align="center"></el-table-column>
            <el-table-column prop="ground" label="地面卫生" align="center"></el-table-column>
            <el-table-column prop="bed" label="床铺卫生" align="center"></el-table-column>
            <el-table-column prop="balcony" label="阳台卫生" align="center"></el-table-column>
            <el-table-column prop="desk" label="书桌卫生" align="center"></el-table-column>
            <el-table-column prop="electricity" label="用电安全" align="center"></el-table-column>
            <el-table-column prop="checkScore" label="综合评价" align="center"></el-table-column>
            <el-table-column prop="uname" label="检查人" align="center"></el-table-column>
            <el-table-column prop="checkTime" label="检查时间" align="center" width="180px"></el-table-column>
          </el-table>
          <div class="lastLine" style="margin-top: 10px">               
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                           :current-page.sync="pageNum" :page-sizes="[10, 20,30,50,100,200,]"
                           :page-size="pageSize"
                           layout="sizes, prev, pager, next" :total="total">      
            </el-pagination>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>

</template>

<script>
    export default {
        data() {
            return {
                sanitary: {
                    buildId: '',
                    uName: '',
                    roomId: '',
                    grade: '',
                    content: '',
                    checkTime: '',
                },
                sanitarys: [],
                tableLoading: false,
                pageNum: 1,
                pageSize: 10,
                total: 0,
                list: [],
            };
        },
        methods: {
            initData: function () {
              var tempdate
                this.tableLoading = true;
                // var _this = this;
                this.getRequest("/sanitary/dor/check/list?pageSize=" + this.pageSize + "&pageNum=" + this.pageNum).then(resp => {
                    this.tableLoading = false;
                    if (resp && resp.status == 200) {
                        this.total = resp.data.obj.total;
                        this.sanitarys = resp.data.obj.data;
                        for (var i = 0; i < this.sanitarys.length; i++) {
                            let  b;
                            b=i+1
                            this.sanitarys[i].listId=b
                            tempdate =this.sanitarys[i].checkTime
                            this.sanitarys[i].checkTime=tempdate.slice(0,tempdate.indexOf("."))
                            switch (this.sanitarys[i].ground) {
                                case 1:
                                    this.sanitarys[i].ground = '100';
                                    break;
                                case 2:
                                    this.sanitarys[i].ground = '90';
                                    break;
                                case 3:
                                    this.sanitarys[i].ground = '80';
                                    break;
                                case 4:
                                    this.sanitarys[i].ground = '60';
                                    break;
                            }
                            switch (this.sanitarys[i].bed) {
                                case 1:
                                    this.sanitarys[i].bed = 100;
                                    break;
                                case 2:
                                    this.sanitarys[i].bed = 90;
                                    break;
                                case 3:
                                    this.sanitarys[i].bed = 80;
                                    break;
                                case 4:
                                    this.sanitarys[i].bed = 60;
                                    break;
                            }
                            switch (this.sanitarys[i].balcony) {
                                case 1:
                                    this.sanitarys[i].balcony = 100;
                                    break;
                                case 2:
                                    this.sanitarys[i].balcony = 90;
                                    break;
                                case 3:
                                    this.sanitarys[i].balcony = 80;
                                    break;
                                case 4:
                                    this.sanitarys[i].balcony = 60;
                                    break;
                            }

                            switch (this.sanitarys[i].desk) {
                                case 1:
                                    this.sanitarys[i].desk = 100;
                                    break;
                                case 2:
                                    this.sanitarys[i].desk = 90;
                                    break;
                                case 3:
                                    this.sanitarys[i].desk = 80;
                                    break;
                                case 4:
                                    this.sanitarys[i].desk = 60;
                                    break;
                            }
                            switch (this.sanitarys[i].electricity) {
                                case 1:
                                    this.sanitarys[i].electricity = 100;
                                    break;
                                case 2:
                                    this.sanitarys[i].electricity = 90;
                                    break;
                                case 3:
                                    this.sanitarys[i].electricity = 80;
                                    break;
                                case 4:
                                    this.sanitarys[i].electricity = 60;
                                    break;
                            }
                            switch (this.sanitarys[i].allSelect) {
                                case 1:
                                    this.sanitarys[i].allSelect = "";
                                    break;
                                case 2:
                                    this.sanitarys[i].allSelect = 90;
                                    break;
                                case 3:
                                    this.sanitarys[i].allSelect = 80;
                                    break;
                                case 4:
                                    this.sanitarys[i].allSelect = 60;
                                    break;
                            }
                        }
                    }
                })
            },
            handleSizeChange(val) {    //分页
                this.pageSize = val;
                this.initData()
            },
            handleCurrentChange(val) {   //分页
                this.pageNum = val;
                this.initData()
            },

        },
        mounted: function () {
            this.initData();
        },

    }
</script>

<style scoped>
  .searchStyle{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    justify-content: left;
  }
  .lastLine {
display:  flex;
flex-direction:  row;
justify-content:  flex-end;
margin:  10px 0 10px 0;
  }


</style>
